﻿Partial Public Class frmLogin
    Dim numberOfTries As Integer
    Dim passwordRetries As Integer = 0

    Dim auth As New ATS.UI.Process.ATSLOCALAUTHENTICATIONServiceReference.AuthenticationServiceSoapClient

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        DialogResult = False
        Application.Current.Shutdown()
    End Sub

    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        Try
            Dim result = auth.Login(txtUserName.Text, txtPassword.Password, True, "").RootResults.FirstOrDefault()
            If result.Roles(0).ToString.ToUpper = "ADMINISTRATOR" Or result.Roles(0).ToString.ToUpper = "SYNCHREADER" Then
                DialogResult = True
                ATSMain.v_username = txtUserName.Text
                Me.Close()
            Else
                MsgBox("Only members of the Administrator or Synch Reader groups are allowed to use this function.", MsgBoxStyle.Information, "User not allowed")
            End If
        Catch ex As Exception
            MsgBox("Please check your username and password.", MsgBoxStyle.Exclamation, "Invalid login")
        End Try
    End Sub

    
End Class